package com.demo2do.boyle.client.web.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.demo2do.core.entity.Result;
import com.demo2do.core.utils.JsonUtils;

@Controller
@RequestMapping("/qiniu")
public class FileUploadController {
	
	@Value("#{config['qiniu.appkey']}")
    private String appkey;
    
    @Value("#{config['qiniu.secretkey']}")
    private String secretkey;
    
    @Value("#{config['qiniu.bucket']}")
    private String bucket;
    
	
	@RequestMapping("/upload-token")
    public @ResponseBody String onCreateUploadToken(@RequestParam(value = "photo", required = false) String keyName) {
		Result result = new Result();
		try{
			// FIXME change fileupload to qiniuUtils use php
	        result.success();
		}catch(Exception e) {
			result.message("获取上传签名失败");
		}
        return JsonUtils.toJsonString(result);
    }
	
	
}
